#include <iostream>
#define ll long long 

using namespace std;


int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int t;
	cin >> t;
	for(int i = 0; i < t; ++i){
		ll x,y;
		cin >> x >> y;
		if(x == 1 || y == 1){
			cout << -1 << endl;
		}else{
			cout << 1 << endl;
		}
		
	}

	return 0;
}

